package com.kingdee.eas.taskmanager.itask.util;

import com.kingdee.bos.BOSException;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.taskmanager.TaskClass;
import com.kingdee.eas.taskmanager.TaskManagerFactory;
import com.kingdee.eas.taskmanager.TaskManagerInfo;
import com.kingdee.eas.taskmanager.TaskState;
import com.kingdee.eas.taskmanager.TaskType;

public class TaskUtil {

	public static boolean addTask(String name, String ctxString, String number, String description) {
		try {
			TaskManagerInfo taskInfo = new TaskManagerInfo();
			taskInfo.setName(name);
			taskInfo.setNumber(number);

			taskInfo.setDescription(description);

			taskInfo.setTaskContext(ctxString);
			taskInfo.setTaskType(TaskType.personhandle);
			taskInfo.setTaskState(TaskState.noexec);
			TaskManagerFactory.getRemoteInstance().save(taskInfo);
		} catch (EASBizException e) {
			e.printStackTrace();
			return false;
		} catch (BOSException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public static boolean addTask(String name, String ctxString, String number, String description, String taskClassValue) {
		try {
			TaskManagerInfo taskInfo = new TaskManagerInfo();
			taskInfo.setName(name);
			taskInfo.setNumber(number);

			taskInfo.setDescription(description);

			taskInfo.setTaskContext(ctxString);
			taskInfo.setTaskState(TaskState.noexec);
			taskInfo.setTaskType(TaskType.personhandle);
			taskInfo.setTaskClass(TaskClass.getEnum(taskClassValue));
			TaskManagerFactory.getRemoteInstance().save(taskInfo);
		} catch (EASBizException e) {
			e.printStackTrace();
			return false;
		} catch (BOSException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

}
